package io.debezium.connector.postgresql.connection;

import io.debezium.annotation.NotThreadSafe;
import io.debezium.connector.postgresql.PostgresConnectorConfig;
import io.debezium.connector.postgresql.PostgresSchema;
import io.debezium.connector.postgresql.TypeRegistry;
import io.debezium.connector.postgresql.spi.SlotCreationResult;
import io.debezium.relational.RelationalTableFilters;

import java.sql.SQLException;
import java.time.Duration;
import java.util.Optional;

@NotThreadSafe
public interface ReplicationConnection extends AutoCloseable {
    ReplicationStream startStreaming(WalPositionLocator var1)
            throws SQLException, InterruptedException;

    ReplicationStream startStreaming(Lsn var1, WalPositionLocator var2)
            throws SQLException, InterruptedException;

    Optional<SlotCreationResult> createReplicationSlot() throws SQLException;

    void initConnection() throws SQLException, InterruptedException;

    boolean isConnected() throws SQLException;

    static Builder builder(PostgresConnectorConfig config) {
        return new PostgresReplicationConnection.ReplicationConnectionBuilder(config);
    }

    void reconnect() throws SQLException;

    public interface Builder {
        String DEFAULT_SLOT_NAME = "debezium";
        String DEFAULT_PUBLICATION_NAME = "dbz_publication";
        boolean DEFAULT_DROP_SLOT_ON_CLOSE = true;

        Builder withSlot(String var1);

        Builder withPublication(String var1);

        Builder withTableFilter(RelationalTableFilters var1);

        Builder withPublicationAutocreateMode(PostgresConnectorConfig.AutoCreateMode var1);

        Builder withPlugin(PostgresConnectorConfig.LogicalDecoder var1);

        Builder dropSlotOnClose(boolean var1);

        Builder statusUpdateInterval(Duration var1);

        Builder withTypeRegistry(TypeRegistry var1);

        Builder withSchema(PostgresSchema var1);

        Builder streamParams(String var1);

        Builder doSnapshot(boolean var1);

        Builder jdbcMetadataConnection(GaussDBConnection var1);

        ReplicationConnection build();
    }
}
